package demo.com.administrator.adapter;


import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Filter;
import android.widget.TextView;

import com.example.administrator.ac.MainActivity;
import com.example.administrator.ac.R;

import java.util.ArrayList;

/**
 * Created by Administrator on 2017/6/27.
 */

public class ListViewAdapter extends BaseAdapter {
    ArrayList<String> order;

    public ListViewAdapter(ArrayList<String> order){
        this.order=order;
    }

    @Override
    public int getCount() {
        return order.size();
    }

    @Override
    public Object getItem(int position) {
        return order.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder vh = null;
        if (convertView == null) {
            convertView = LayoutInflater.from(MainActivity.mcontext).inflate(R.layout.listitem, null);
            vh=new ViewHolder();
            vh.ordernumber=(TextView)convertView.findViewById(R.id.ordernumber);
            vh.user=(TextView)convertView.findViewById(R.id.user);
            vh.worker=(TextView)convertView.findViewById(R.id.worker);
            convertView.setTag(vh);
        }else{
            vh=(ViewHolder)convertView.getTag();
        }
        vh.ordernumber.setText(order.get(position));
        vh.worker.setText(order.get(position));
        vh.user.setText(order.get(position));
        return convertView;

    }

   private  class ViewHolder {
           TextView ordernumber;
       TextView user;
       TextView worker;
    }


}